package com.example.happiness.mapper;

import com.example.happiness.pojo.Feedback;
import com.example.happiness.pojo.adminvo.AdminFeedbackVO;
import com.example.happiness.pojo.uservo.UserReviewsVO;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Select;

import java.util.List;

@Mapper
public interface FeedbackMapper {
    int deleteByPrimaryKey(Integer fid);

    int insert(Feedback record);

    int insertSelective(Feedback record);

    Feedback selectByPrimaryKey(Integer fid);

    int updateByPrimaryKeySelective(Feedback record);

    int updateByPrimaryKey(Feedback record);

    @Select("select f.orderid,s.image,s.sname,s.price,f.score,f.content from feedback f,serve s,`order` o\n" +
            "where o.orderid=f.orderid and o.sid=s.sid and f.userid=#{userid}")
    List<UserReviewsVO> getFeedback(String userid);

    @Select("select f.fid,f.userid,u.realname as uname,f.content,f.orderid,f.eid,e.realname as ename,f.score\n" +
            "from feedback f,employee e,user u where f.userid=u.userid and f.eid=e.employeeid")
    List<AdminFeedbackVO> getFeedbackList();

    @Select("select score from feedback where orderid = #{orderid}")
    Feedback getScore(String orderid);
}